# Maintainer: Morten Linderud <foxboron@archlinux.org>

pkgname=libnvme
pkgver=1.6
pkgrel=2
pkgdesc="C Library for NVM Express on Linux"
arch=('loong64' 'x86_64')
url="https://github.com/linux-nvme/libnvme"
license=('LGPL2.1')
makedepends=('systemd' 'meson' 'asciidoc' 'python' 'swig')
depends=('json-c' 'openssl' 'keyutils' 'dbus')
source=(
	"$pkgname-$pkgver.tar.gz::https://github.com/linux-nvme/${pkgname}/archive/v${pkgver}.tar.gz"
	$pkgname-1.6-allocate_aligned_payloads.patch::https://github.com/linux-nvme/libnvme/pull/727.patch
)
sha256sums=('0dd8ba8b655abe78c09833edb66632aa6bee82aebf117dd252ded968deaaeec7'
            '21bbdbb312af5c5d1604ebf9d72b28d260083dbb1691357255d83a2e5dc63a10')

prepare() {
	# backport of https://github.com/linux-nvme/libnvme/pull/727
	# fixes https://bugs.archlinux.org/task/79760 (with libblockdev >= 3.0.4)
	patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-1.6-allocate_aligned_payloads.patch
}

build() {
	cd "${pkgname}-${pkgver}"
    arch-meson \
	-Dlibdbus=auto \
	-Ddocs-build=true \
	.build
}

package() {
	cd "${pkgname}-${pkgver}"
	DESTDIR="$pkgdir" meson install -C .build
}
